package com.zzyl.nursing.controller;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.domain.R;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.nursing.domain.Reservation;
import com.zzyl.nursing.dto.ReservationPageDto;
import com.zzyl.nursing.service.IReservationService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zzw
 * @date 2025/6/6
 * @description 预约信息
 */
@RestController
@RequestMapping("/nursing/reservation")
public class NursingReservationController extends BaseController {

    @Autowired
    private IReservationService reservationService;

    /**
     * 查询预约信息列表
     */
    @GetMapping("/list")
    @ApiOperation("查询预约信息列表")
    public TableDataInfo<Reservation> list(ReservationPageDto reservationPageDto) {
        startPage();
        List<Reservation> list = reservationService.selectReservationList(reservationPageDto);
        return getDataTable(list);
    }

    /**
     * 根据id查询预约信息
     */
    @GetMapping("/{id}")
    @ApiOperation("根据id查询预约信息")
    public R<Reservation> getById(@PathVariable Long id) {
        Reservation reservation = reservationService.getById(id);
        return R.ok(reservation);
    }

    /**
     * 新增预约信息
     */
    @PostMapping
    @ApiOperation("新增预约信息")
    public AjaxResult add(@RequestBody Reservation reservation) {
        reservationService.save(reservation);
        return success();
    }

    /**
     * 修改预约信息
     */
    @PutMapping
    @ApiOperation("修改预约信息")
    public AjaxResult update(@RequestBody Reservation reservation) {
        reservationService.updateReservationById(reservation);
        return success();
    }

    /**
     * 删除预约信息
     */
    @DeleteMapping("/{id}")
    @ApiOperation("删除预约信息")
    public AjaxResult remove(@PathVariable Long id) {
        reservationService.removeReservationById(id);
        return success();
    }
}
